package com.example.web03homework.service.impl;

import com.example.web03homework.dao.BookDao;
import com.example.web03homework.dao.CategoryDao;
import com.example.web03homework.pojo.Book;
import com.example.web03homework.pojo.Category;
import com.example.web03homework.pojo.extend.BookExtend;
import com.example.web03homework.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {

    @Autowired
    private BookDao bookDao;

    @Autowired
    private CategoryDao categoryDao;

    @Override
    public List<BookExtend> getBooksByCondition(String keyword, Integer categoryId) {
        // 实现查询逻辑
        return null;
    }

    @Override
    public void addBook(Book book) {
        bookDao.insert(book);
    }

    @Override
    public void modifyBookStatus(Integer id, Integer status) {
        bookDao.updateStatus(id, status);
    }

    @Override
    public void removeBatchByIds(List<Integer> ids) {
        bookDao.deleteByIds(ids);
    }

    // 实现其他方法
    public Book getById(Integer id) {
        return bookDao.getById(id);
    }

    public List<Book> getByCondition(String keyword, Integer categoryId) {
        return bookDao.getByCondition(keyword, categoryId);
    }

    public void updateBook(Book book) {
        bookDao.update(book);
    }

    public void deleteById(Integer id) {
        bookDao.deleteById(id);
    }

    public List<Category> getAllCategories() {
        return categoryDao.getAllCategories();
    }
}
